package com.vishnu.main;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.vishnu.pojo.Employee;
import com.vishnu.pojo.Product;

public class PracticeOnClearMethod {

	public static void main(String[] args) {
		Configuration cfg=new Configuration();
		cfg.configure("hib.cfg.xml");
		SessionFactory sf=cfg.buildSessionFactory();
		Session hsession=sf.openSession();
		Transaction tx=hsession.beginTransaction();
		Product employee=new Product();
		employee.setProductId(5);
		employee.setProductName("bindhumadhavi");
		employee.setProductPrice(5000.);
		hsession.save(employee);
		System.out.println("employee:"+hsession.contains(employee));
/*		Employee employee2=new Employee();
		employee2.setEmployeeId(6);
		employee2.setEmployeeName("madhavi");
		employee2.setEmployeeSalary(4500.);
		hsession.merge(employee2);*/
		System.out.println("employee:"+hsession.contains(employee));
//		System.out.println("employee2:"+hsession.contains(employee2));
	   
//		hsession.clear();
		
/*		hsession.evict(employee);
		hsession.evict(employee2);*/
		System.out.println("------after clear---------");
		System.out.println("employee:"+hsession.contains(employee));
//		System.out.println("employee2:"+hsession.contains(employee2));
		
		tx.commit();
		hsession.close();
		sf.close();
		
	}
}
